{% load blog_tags keyword_tags mezzanine_tags i18n future %}

{% block blog_feeds %}
<section class="section--center mdl-grid mdl-grid--no-spacing mdl-shadow--2dp recent-post">
    <div class="mdl-card__title mdl-card--border mdl-card--expand">
        <h3 class="mdl-card__title-text">{% trans "Feeds" %}</h3>
    </div>
    <div class="mdl-card__supporting-text">
    {% if tag %}
        <a href="{% url "blog_post_feed_tag" tag.slug "rss" %}">{% trans "RSS" %}</a> /
        <a href="{% url "blog_post_feed_tag" tag.slug "atom" %}">{% trans "Atom" %}</a>
    {% endif %}
    {% if category %}
        <a href="{% url "blog_post_feed_category" category.slug "rss" %}">{% trans "RSS" %}</a> /
        <a href="{% url "blog_post_feed_category" category.slug "atom" %}">{% trans "Atom" %}</a>
    {% endif %}
    {% if author %}
        <a href="{% url "blog_post_feed_author" author.username "rss" %}">{% trans "RSS" %}</a> /
        <a href="{% url "blog_post_feed_author" author.username "atom" %}">{% trans "Atom" %}</a>
    {% endif %}
    {% if not tag and not category and not author %}
        <a href="{% url "blog_post_feed" "rss" %}">{% trans "RSS" %}</a> /
        <a href="{% url "blog_post_feed" "atom" %}">{% trans "Atom" %}</a>
    {% endif %}
    </div>
</section>
{% endblock %}

{% block blog_recent_posts %}
{% blog_recent_posts 10 as recent_posts %}
{% if recent_posts %}
<section class="section--center mdl-grid mdl-shadow--2dp recent-post">
    <div class="mdl-card__title mdl-card--border mdl-card--expand">
        <h3 class="mdl-card__title-text">{% trans "最近文章" %}</h3>
    </div>
<div class="mdl-card__supporting-text">
<ul class="list-unstyled">
{% for recent_post in recent_posts %}
<li>
    {% spaceless %}
    <a href="{{ recent_post.get_absolute_url }}">
        {% if settings.BLOG_USE_FEATURED_IMAGE and recent_post.featured_image %}
        <img src="{{ MEDIA_URL }}{% thumbnail recent_post.featured_image 24 24 %}">
        {% endif %}
    {{ recent_post.title }}
    </a>
    {% endspaceless %}
</li>
{% endfor %}
</ul></div>
</section>
{% endif %}
{% endblock %}

{% include "includes/user_info.html" %}

{% include "blog/includes/events.html" %}

{% block blog_months %}
{% blog_months as months %}
{% if months %}
<section class="section--center mdl-grid mdl-grid--no-spacing mdl-shadow--2dp recent-post">
<div class="mdl-card__title mdl-card--border mdl-card--expand">
    <h3 class="mdl-card__title-text">{% trans "存档" %}</h3>
</div>
<ul class="mdl-card__supporting-text list-unstyled">
{% for month in months %}
    {% ifchanged month.date.year %}
        {% if not forloop.first %}</ul>{% endif %}
        <h6>{{ month.date.year }}</h6><ul class="list-unstyled">
    {% endifchanged %}
    <li><a href="{% url "blog_post_list_month" year=month.date.year month=month.date.month %}"
        >{{ month.date|date:"F" }}</a> ({{ month.post_count }})</li>
{% endfor %}
</ul>
</section>
{% endif %}
{% endblock %}

{% block blog_categories %}
{% blog_categories as categories %}
{% if categories %}
<section class="section--center mdl-grid mdl-grid--no-spacing mdl-shadow--2dp recent-post">
    <div class="mdl-card__title mdl-card--border mdl-card--expand">
        <h3 class="mdl-card__title-text">{% trans "分类" %}</h3>
    </div>
<ul class="mdl-card__supporting-text list-unstyled">
{% for category in categories %}
    {% if category.post_count >= 5 %}
<li><a href="{% url "blog_post_list_category" category.slug %}"
    >{{ category }}</a> ({{ category.post_count }})</li>
    {% endif %}
{% endfor %}
</ul></section>
{% endif %}
{% endblock %}

{% block blog_keywords %}
{% keywords_for blog.blogpost as tags %}
{% if tags %}
<section class="section--center mdl-grid mdl-grid--no-spacing mdl-shadow--2dp recent-post">
    <div class="mdl-card__title mdl-card--border mdl-card--expand">
        <h3 class="mdl-card__title-text">{% trans "标签" %}</h3>
    </div>
<ul class="mdl-card__supporting-text list-unstyled tag-cloud">
{% for tag in tags %}
{% if tag.item_count >= 8 %}
<li>
    <a href="{% url "blog_post_list_tag" tag.slug %}"
        class="tag-weight-{{ tag.weight }}">{{ tag }}</a>
    ({{ tag.item_count }})
</li>
{% endif %}
{% endfor %}
</ul></section>
{% endif %}
{% endblock %}

{% block blog_authors %}
{% blog_authors as authors %}
{% if authors %}
<section class="section--center mdl-grid mdl-grid--no-spacing mdl-shadow--2dp recent-post">
    <div class="mdl-card__title mdl-card--border mdl-card--expand">
        <h3 class="mdl-card__title-text">{% trans "作者" %}</h3>
    </div>
<ul class="mdl-card__supporting-text list-unstyled tag-cloud">
{% for author in authors %}
    <li><a href="{% url "blog_post_list_author" author.username %}"
        >{{ author.get_full_name|default:author.username }}</a>
        ({{ author.post_count }})</li>
{% endfor %}
</ul></section>
{% endif %}
{% endblock %}